
function selectUser(val) {
	var url = "getGrouphomeByPhone.action?status=" + val;
	openWindow(url, 700, 420);
}
function setValue(value, val) {
	var arr = eval(value);
	var names = "";
	var ids = "";
	for (i = 0; i < arr.length; i++) {
		ids = ids + "," + arr[i].value;
		names = names + "," + arr[i].name;
	}
	if (names.length > 0) {
		names = names.substring(1);
		ids = ids.substring(1);
	}
	document.getElementById(val + "names").value = names;
	document.getElementById(val + "ids").value = ids;
}
function getOldValue(val) {
	var ids = document.getElementById(val + "ids").value;
	var names = document.getElementById(val + "names").value;
	var array = "";
	if (ids != "" && ids != "null") {
		var idarray = ids.split(",");
		var namearray = names.split(",");
		for (var i = 0; i < idarray.length; i++) {
			if (i == 0) {
				array += "{\"value\":" + idarray[i] + ",\"name\":\"" + namearray[i] + "\"}";
			} else {
				array += ",{\"value\":" + idarray[i] + ",\"name\":\"" + namearray[i] + "\"}";
			}
		}
	}
	return array;
}
function valiadValue(value) {
	var snames = $("#snames").val();
	var outReceivers = $("#outReceivers").val();
	var content = $("#content").val();
	if ((snames == null || snames == "") && (outReceivers == null || outReceivers == "")) {
		alert("\u6536\u4ef6\u4eba\u548c\u5916\u90e8\u8054\u7cfb\u4eba\u5fc5\u586b\u4e00\u4e2a\uff01");
		return;
	}
	if (!checkPhone(outReceivers)) {
		alert("\u5916\u90e8\u8054\u7cfb\u4eba\u683c\u5f0f\u6709\u8bef\uff0c\u8bf7\u6309\u7167\u8981\u6c42\u8f93\u5165\uff01");
		return;
	}
	if (content == null || content == "") {
		alert("\u6b63\u6587\u4e0d\u80fd\u4e3a\u7a7a\uff01");
		return;
	}
	if (content.length > 200) {
		alert("\u4fe1\u606f\u5185\u5bb9\u592a\u957f\uff0c\u6700\u591a\u5141\u8bb8200\u4e2a\u5b57\uff01");
		return;
	}
	if (value == "draft") {
		document.messageForm.action = "draftMessage.action";
	} else {
		if (value == "send") {
			document.messageForm.action = "sendMessage.action";
		}
	}
	document.messageForm.submit();
}
function valid() {
	var keyCode = event.keyCode;
	if ((keyCode >= 48 && keyCode <= 57) || keyCode == 188 || keyCode == 8) {
		event.returnValue = true;
	} else {
		event.returnValue = false;
	}
}
function checkPhone(outReceivers) {
	for (var i = 0; i < outReceivers.length; i++) {
		if (!checkChar(outReceivers.charAt(i))) {
			return false;
		}
	}
	return true;
}
function checkChar(code) {
	if (/[\x00-\xFF]/.test(code)) {
		return true;
	} else {
		return false;
	}
}
function warn(val) {
	textLength(val,200);
	var count = 200 - val.value.length;
	$("#warn").html(count);
}

